home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1378 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.4 KB  |  60 lines

  1. Path: newsroom.hitc.com!usenet
  2. From: Chris Ruegger <cruegger@eos.hitc.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Inline function problem
  5. Date: 10 Jan 1996 18:29:25 GMT
  6. Organization: Hughes Information Technology Corporation
  7. Message-ID: <4d10i5$bc3@newsroom.hitc.com>
  8. NNTP-Posting-Host: rainman.hitc.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.12 (X11; I; SunOS 5.4 sun4m)
  13. X-URL: news:comp.lang.c++
  14.  
  15. I thought I was able to do the following but I am getting an
  16. unresolved reference:
  17.  
  18. (Running SunOS 5.4)
  19.  
  20. // in file foo.H
  21. class FOO {
  22. public:
  23.   int x();
  24. private:
  25.   int x_;
  26. };
  27.  
  28. // in file foo.C:
  29. #include <foo.H>
  30. inline int FOO::x() {return x_;}
  31.  
  32. // main.C
  33. #include <foo.H>
  34. #include <iostream.h>
  35. int main(int argc, char *argv[])
  36. {
  37.   FOO myfoo;
  38.   cout << myfoo.x() << endl;
  39. }
  40.  
  41. When I try to link, I get:
  42.  
  43. Undefined                       first referenced
  44.  symbol                             in file
  45. FOO::x(void)                         main.o
  46. ld: fatal: Symbol referencing errors. No output written to main
  47.  
  48. }
  49.  
  50.  
  51. Is this a compiler specific thing or illegal C++?
  52.  
  53.  
  54.  
  55. --------------------------------------------------------------------
  56. Christopher Ruegger                 phone:   (301) 925-1164
  57.                                     Email:   cruegger@eos.hitc.com
  58.                                              car@access.digex.com
  59.  
  60.